<template>
  <div>
      <van-nav-bar
        :title="comment.reply_count ? comment.reply_count +'条评论':'暂无回复'"
      >
      <template  #left>
        <van-icon @click="$emit('close-reply')" name="cross" />
      </template>
      </van-nav-bar>
      <!-- 中间内容 -->
      <div class="scroll-center">
          <CommentItem :row="comment"/>
          <van-cell title="全部回复"/>
          <CommentList type="c" :source="comment.com_id" :list="list">123</CommentList>
      </div>
      <!-- 底部按钮 -->
      <div class="post-warp">
          <van-button @click="isShowReplyPost=true" round>评论</van-button>
      </div>
      <van-popup v-model="isShowReplyPost" position="bottom" >
        <CommentPost @on-post-sucess="onPostSuccess" :target="comment.com_id" :artId="$route.params.articleId" />
      </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/comment-item'
import CommentList from '@/components/comment-list.vue'
import CommentPost from './comment-post.vue'
export default {
  data () {
    return {
      list: [],
      isShowReplyPost: false
    }
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  components: {
    CommentItem,
    CommentList,
    CommentPost
  },
  created () {

  },

  methods: {
    onPostSuccess (obj) {
      this.list.unshift(obj)
      this.isShowReplyPost = false
    }
  }
}
</script>

<style scoped lang="less">
  .post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
  }
  }
  .scroll-center{
    position: absolute;
    top: 92px;
    bottom: 102px;
    width: 100%;
    overflow-y:scroll;
  }
</style>
